<%@ page import="cn.org.eshow.common.ShopDataVar" %>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8"
         contentType="text/html;charset=utf-8" %>
<%@ include file="/common/taglibs.jsp" %>
<head>
    <title>博文添加</title>

</head>
<body>
<div id="wrapper">
    <c:set var="left">blog</c:set>
    <%@ include file="/include/left/operation.jsp" %>

    <div id="page-wrapper" class="gray-bg">


        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-10">
                <h2>博文添加</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="${ctx}/blog/">运营管理</a>
                    </li>
                    <li>
                        <a>博文管理</a>
                    </li>
                    <li class="active">
                        <strong>博文添加</strong>
                    </li>
                </ol>
            </div>
        </div>


        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content">
                            <s:form id="blogFrom" action="blog!save.action" class="form-horizontal" method="post" namespace="">
                                <input type="hidden" name="redirect" value="/blog/"/>

                                <div class="form-group"><label class="col-sm-2 control-label">博文标题</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="blog.title" class="form-control  validate[required]" placeholder="请输入博文标题">
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">分类</label>
                                    <div class="col-sm-6">
                                        <input type="text" name="blog.category" value="<%= ShopDataVar.category.专题.toString() %>" class="form-control  validate[required]" readonly placeholder="请输入分类">
                                    </div>
                                </div>

                                <%--<div class="form-group"><label class="col-sm-2 control-label">风格</label>--%>
                                    <%--<div class="col-sm-6">--%>
                                        <%--<c:set var="styles" value="<%= cn.org.eshow.common.ShopDataVar.style.values() %>"/>--%>
                                        <%--<select name="blog.style" class="input_md validate[required]">--%>
                                            <%--<c:forEach var="style" items="${styles}">--%>
                                                <%--<option value="${style}">${style}</option>--%>
                                            <%--</c:forEach>--%>
                                        <%--</select>--%>
                                    <%--</div>--%>
                                <%--</div>--%>

                                <%--<div class="form-group"><label class="col-sm-2 control-label">年龄</label>--%>
                                    <%--<div class="col-sm-6">--%>
                                        <%--<select name="blog.age" class="input_md validate[required]">--%>
                                            <%--<option value="1">0-20</option>--%>
                                            <%--<option value="2">21-40</option>--%>
                                            <%--<option value="3">41-60</option>--%>
                                        <%--</select>--%>
                                    <%--</div>--%>
                                <%--</div>--%>

                                <%--<div class="form-group"><label class="col-sm-2 control-label">颜色</label>--%>
                                    <%--<div class="col-sm-6">--%>
                                        <%--<c:set var="colors" value="<%= cn.org.eshow.common.ShopDataVar.color.values() %>"/>--%>
                                        <%--<select name="blog.color" class="input_md validate[required]">--%>
                                            <%--<c:forEach var="color" items="${colors}">--%>
                                                <%--<option value="${color}">${color}</option>--%>
                                            <%--</c:forEach>--%>
                                        <%--</select>--%>
                                    <%--</div>--%>
                                <%--</div>--%>

                                <div class="form-group"><label class="col-sm-2 control-label">正文</label>
                                    <div class="col-sm-10">
                                        <textarea class="form-control" name="blog.content" id="content"></textarea>
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">图片</label>
                                    <div class="col-sm-10">
                                        <div class="m-upimgview">
                                            <img  id="preview-img" height="200px;" width="200px;" src="<%=QiniuConfig.NONE_IMG%>!small.jpg">
                                            <input id="upimg" type="hidden" name="blog.img"
                                                   value="<%=QiniuConfig.NONE_IMG%>">

                                            <input id="fileupload" name="file" class="hidden" type="file"/>

                                            <div class="progress progress-mini">
                                                <div id="progress" style="" class="progress-bar"></div>
                                            </div>
                                        </div>

                                        <a class="btn btn-primary" href="javascript:;" onclick="fileUp('preview-img','upimg','progress','fileupload');">选择一个文件</a>
                                    </div>
                                </div>

                                <div class="form-group"><label class="col-sm-2 control-label">所属商品</label>
                                    <s:action name="product!search" var="productList" executeResult="false">
                                        <s:param name="query.enabled">true</s:param>
                                        <s:param name="query.state">1</s:param>
                                        <s:param name="query.pagesize">50</s:param>
                                        <s:param name="query.desc">false</s:param>
                                        <s:param name="query.order">addTime</s:param>
                                    </s:action>
                                    <div class="col-sm-6">
                                        <select name="blog.product.id" class="input_md validate[required]">
                                            <s:iterator value="%{#productList.products}">
                                                <option ${id==view.blog.product.id?'selected="selected"':''} value="${id}">${name}</option>
                                            </s:iterator>
                                        </select>
                                    </div>
                                </div>

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-white" type="button"
                                                onclick="javascript:history.back(-1);">取消
                                        </button>
                                        <button class="btn btn-primary" id="submitButton" type="submit" data-loading-text="提交中..." >发布
                                        </button>
                                    </div>
                                </div>
                            </s:form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <%@ include file="/common/footer.jsp" %>


    </div>

</div>

<%@ include file="/common/scripts.jsp" %>
<%@ include file="/common/validate.jsp" %>
<%@ include file="/common/script/umeditor.jsp" %>
<%@ include file="/common/script/fileupload.jsp" %>


<script>
    $('#blogFrom').validationEngine({
        promptPosition: 'topLeft',
        onValidationComplete:  function(form, status){//验证回调函数（阻断提交）
            if(status){//当所有验证通过后再执行
                submitForm();
            }
        }
    });

    getUMEditor('content');

    function submitForm() {
        var _content = $('#content').val();
        if (_content == null || _content == '') {
            layer.msg('请输入有效正文内容');
        } else {
            $('#submitButton').button('loading')
            $('#blogFrom').submit();
        }


    }
</script>

</body>

